// pages/index/index.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    
    //键名：键值
    //数据类型：字符串（string）数值（number）、布尔值（Boolean）未定义（undefined）空格（null）对象（object）数组（array）函数（function）
    //message:"hello world",
    //age:"30"
    imgList:[
      "../../images/swiper1.jpg",
      "../../images/swiper2.jpg",
      "../../images/swiper3.jpg",
    ],

    
    //定义图片的高度
    imghei:"",
    lists:[
      "../../images/list1.png",
      "../../images/list2.png",
      "../../images/list3.png",
      "../../images/list4.png",
      "../../images/list5.png",
      "../../images/list6.png",
      "../../images/list7.png",
      "../../images/list8.png",
      "../../images/list9.png",
      "../../images/list10.png",
    ],
    selectList:[
        {
          text:"更多小米产品",
          titleImg:"../../images/select.jpg",
          phone:[
            {
              id:1,
              num:1,
              src:"../../images/select1.jpg",
              name:"小米10",
              art:"骁龙865/一亿像素相机",
              new:3399,
              old:"¥9999",
              checked:true,
              isCollection:true
            },
            {
              id:2,
              num:1,
              src:"../../images/select2.jpg",
              name:"红米abc",
              art:"骁龙865/一亿像素相机",
              new:1399,
              old:"¥9899",
              checked:true,
              isCollection:true
            },
            {
              id:3,
              num:1,
              src:"../../images/select3.jpg",
              name:"小米abc",
              art:"骁龙123/6400w像素相机",
              new:2399,
              old:"¥2999",
              checked:true,
              isCollection:true
            },
            {
              id:4,
              num:1,
              src:"../../images/select4.jpg",
              name:"红米K30",
              art:"骁龙321/6400w像素相机",
              new:666,
              old:"¥666",
              checked:true,
              isCollection:true
            },
            {
              id:5,
              num:1,
              src:"../../images/select5.jpg",
              name:"红米K30",
              art:"骁龙321/6400w像素相机",
              new:666,
              old:"¥666",
              checked:true,
              isCollection:true
            },
            {
              id:6,
              num:1,
              src:"../../images/select6.jpg",
              name:"红米K30",
              art:"骁龙321/6400w像素相机",
              new:"666",
              old:"¥666",
              checked:true,
              isCollection:true
            }
      
          ],
        }
    ],
  },
  
//轮播图缩放后高度
    imgH:function(event){
      //console.log(event)
      //获取图片的宽高度
      let imgWid = event.detail.width
      let imgHei = event.detail.height
      let winWid = wx.getSystemInfoSync().windowWidth
      //图片宽度为屏幕大小时，缩放比以后的图片高度
      let hei = winWid/imgWid * imgHei
      //将缩放后的图片高度修改到初始数据中
      this.setData({
        imghei:hei
      })
      console.log(hei)
    },
  /**
   * 生命周期函数--监听页面加载
   */

   toDetails:function(e){
     let {key} = e.target.dataset
     let {phone} = this.data.selectList[0]
     let good = phone[key]
     wx.setStorageSync('detailsList', [good])

     wx.navigateTo({
       url: '/pages/details/details',
     })
   },
  onLoad: function (options) {
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})